package com.example.controller;

import com.example.common.Result;
import com.example.entity.Log;
import com.example.entity.Params;
import com.example.service.LogService;
import com.github.pagehelper.PageInfo;
import jakarta.annotation.Resource;
import org.springframework.web.bind.annotation.*;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpSession;

@RestController
@RequestMapping("/log")
public class LogController {

    @Resource
    private LogService logService;

    @PostMapping("/search")
    public Result findLog(@RequestBody Params params){
        PageInfo<Log> info = logService.findLog(params);
        return Result.success(info);
    }

    @PostMapping("/add")
    public Result save(@RequestBody Log log, HttpServletRequest request){
            logService.add(log);
        return Result.success();
    }

    @DeleteMapping("/del/{logId}")
    public Result delete(@PathVariable Integer logId){
        logService.del(logId);
        return Result.success();
    }

}
